<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>滚动体故障数据可视化分析系统</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/Chart.js/4.4.0/chart.min.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        .chart-container {
            position: relative;
            height: 300px;
            margin: 20px 0;
        }
        .feature-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
    </style>
</head>
<body class="bg-gray-100">
    <div class="container mx-auto px-4 py-8">
        <h1 class="text-3xl font-bold text-center mb-8 text-gray-800">
            <i class="fas fa-chart-line mr-2"></i>
            滚动体故障数据可视化分析系统
        </h1>
        
        <!-- 文件上传区域 -->
        <div class="bg-white rounded-lg shadow-md p-6 mb-6">
            <h2 class="text-xl font-semibold mb-4">数据上传</h2>
            <div class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center" id="dropZone">
                <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-4"></i>
                <p class="text-gray-600 mb-2">拖拽.mat文件到此处或点击选择文件</p>
                <input type="file" id="fileInput" accept=".mat" class="hidden">
                <button onclick="document.getElementById('fileInput').click()" 
                        class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
                    选择文件
                </button>
            </div>
            <div id="uploadStatus" class="mt-4 text-center"></div>
        </div>

        <!-- 特征统计卡片 -->
        <div id="featuresSection" class="hidden">
            <h2 class="text-xl font-semibold mb-4">故障特征统计</h2>
            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4 mb-6">
                <div class="feature-card rounded-lg p-4 text-center">
                    <i class="fas fa-wave-square text-2xl mb-2"></i>
                    <h3 class="font-semibold">RMS</h3>
                    <p id="rmsValue" class="text-2xl font-bold">-</p>
                </div>
                <div class="feature-card rounded-lg p-4 text-center">
                    <i class="fas fa-mountain text-2xl mb-2"></i>
                    <h3 class="font-semibold">峰值</h3>
                    <p id="peakValue" class="text-2xl font-bold">-</p>
                </div>
                <div class="feature-card rounded-lg p-4 text-center">
                    <i class="fas fa-chart-area text-2xl mb-2"></i>
                    <h3 class="font-semibold">峭度</h3>
                    <p id="kurtosisValue" class="text-2xl font-bold">-</p>
                </div>
                <div class="feature-card rounded-lg p-4 text-center">
                    <i class="fas fa-waveform-lines text-2xl mb-2"></i>
                    <h3 class="font-semibold">主频(Hz)</h3>
                    <p id="maxFreqValue" class="text-2xl font-bold">-</p>
                </div>
                <div class="feature-card rounded-lg p-4 text-center">
                    <i class="fas fa-signal text-2xl mb-2"></i>
                    <h3 class="font-semibold">主频幅值</h3>
                    <p id="maxAmpValue" class="text-2xl font-bold">-</p>
                </div>
            </div>

            <!-- 图表区域 -->
            <div class="bg-white rounded-lg shadow-md p-6 mb-6">
                <h3 class="text-lg font-semibold mb-4">时域波形</h3>
                <div class="chart-container">
                    <canvas id="timeChart"></canvas>
                </div>
                <div class="flex justify-center space-x-4 mt-4">
                    <button onclick="zoomIn()" class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
                        <i class="fas fa-search-plus mr-1"></i>放大
                    </button>
                    <button onclick="zoomOut()" class="bg-yellow-500 text-white px-4 py-2 rounded hover:bg-yellow-600">
                        <i class="fas fa-search-minus mr-1"></i>缩小
                    </button>
                    <button onclick="resetZoom()" class="bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600">
                        <i class="fas fa-undo mr-1"></i>重置
                    </button>
                </div>
            </div>

            <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                <div class="bg-white rounded-lg shadow-md p-6">
                    <h3 class="text-lg font-semibold mb-4">频谱图</h3>
                    <div class="chart-container">
                        <canvas id="spectrumChart"></canvas>
                    </div>
                </div>
                
                <div class="bg-white rounded-lg shadow-md p-6">
                    <h3 class="text-lg font-semibold mb-4">包络谱</h3>
                    <div class="chart-container">
                        <canvas id="envelopeChart"></canvas>
                    </div>
                </div>
            </div>

            <!-- 导出按钮 -->
            <div class="text-center mt-6">
                <button onclick="exportCSV()" class="bg-purple-500 text-white px-6 py-3 rounded-lg hover:bg-purple-600">
                    <i class="fas fa-download mr-2"></i>
                    导出CSV报告
                </button>
            </div>
        </div>
    </div>

    <script src="app.js"></script>
</body>
</html>
